#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using namespace std;
class Solution {
public:
    /**
     * @param nums: A list of integers.
     * @return: A list of permutations.
     */
   int permute(vector<int> nums) {
        // write your code here
        std::sort(nums.begin(),nums.end());
        vector<vector<int>>res;
		vector<int>distance;
		int min;
        do{
            res.push_back(nums);
        }while(next_permutation(nums.begin(),nums.end()));
		for(int i=0;i<res.size();i++)
		{    distance[i]=0;
		     
			for(int j=0;j<res[i].size();j++)
			{
				if(j==0)
				{
					for(int k=0;k<res[0].size();k++)
					{
						distance[0]+=res[0][k];
					}
					min=distance[0];
				}
				else{

				distance[i]+=res[i][j];
				if(distance[i]>min)
					break;
			}
			
		}
		 return min;
       // return res;
		}
    };
int main(){

vector<int> arr;
arr.resize(4);
for(int i=0;i<4;i++){
	scanf("%d",arr[i]);
}
printf("%d",permute(arr));
system("pause");
return 0;


}

